import type { CartItem } from '@/types/cart'
import { http } from '@/utils/http'

// 加入购物车
export const putMemberCartApi = (
  skuId: string,
  count: number,
) => {
  return http({
    method: 'POST',
    url: '/member/cart',
    data: {
      skuId,
      count,
    },
  })
}
// 获取购物车
export const getMemberCartApi = () => {
  return http<CartItem[]>({
    method: 'GET',
    url: '/member/cart',
  })
}
// 修改购物车单品
export const memberCartBySkuIdApi = (
  skuId: string,
  data: { selected?: boolean; count?: number },
) => {
  return http({
    method: 'PUT',
    url: `/member/cart/${skuId}`,
    data,
  })
}
// 购物车全选/取消全选
export const memberCartSelectedApi = (selected: boolean) => {
  return http({
    method: 'PUT',
    url: '/member/cart/selected',
    data: { selected },
  })
}
